<!--  -->
<template>
 <div>
      <addData>
    <template #btnText>
      <div>
        <el-button type="default">添加</el-button>
      </div>
    </template>
  </addData>

  <!--表格数据  -->
  <el-table :data="tableData" border style="width: 100%">
    <el-table-column align="center" prop="id" label="编号" width="100" />
    <el-table-column align="center" prop="title" label="活动标题" />
    <el-table-column align="center" prop="recommendStatus" label="活动状态">
      <template v-slot:default="scope">
        {{ scope.row.recommendStatus ? "活动进行中" : "活动未开始" }}
      </template>
    </el-table-column>

    <el-table-column label="开始时间" prop="startDate" align="center">
      <template #default="scope">
        {{
          scope.row.startDate
            ? moment(scope.row.startDate).format("YYYY-MM-DD HH:mm:ss")
            : ""
        }}
      </template>
    </el-table-column>

    <el-table-column label="结束时间" prop="endDate" align="center">
      <template #default="scope">
        {{
          scope.row.endDate
            ? moment(scope.row.endDate).format("YYYY-MM-DD HH:mm:ss")
            : ""
        }}
      </template>
    </el-table-column>
    <el-table-column align="center" prop="name" label="操作"> </el-table-column>
  </el-table>
     <!-- 分页插件 -->
    <Pagination
      :total="total"
      :pageSize="pageSize"
      :currentPageNum="currentPageNum"
      :currentPageSize="currentPageSize"
    ></Pagination>
 </div>
</template>

<script lang="ts" setup>
import { reactive, toRefs, ref } from "vue";
import addData from "../../components/addData.vue";
import Pagination from "../../components/Pagination.vue";
import moment from "moment";
import { flashProductRelationListApi } from "../../request/api";
import { useRoute } from "vue-router";

const route = useRoute();

const state = reactive<{
  tableData: {}[];
  total: number;
  pageSize: number[];
  currentPageNum: number;
  currentPageSize: number;
}>({
  tableData: [],
  pageSize: [5, 10, 15], // 分页插件选择一页显示n条数据的数组
  total: 0, // 列表数据总条数
  currentPageNum: 1, // 当前显示的是第几页
  currentPageSize: 10, // 当前一页显示n条数据
});

const { tableData, total, currentPageNum, currentPageSize, pageSize } =
  toRefs(state);

//发送请求
const flashPromotionId = route.query.flashPromotionId;
const flashPromotionSessionId = route.query.flashPromotionSessionId;
flashProductRelationListApi({
  pageNum: 1,
  pageSize: 5,
  flashPromotionId,
  flashPromotionSessionId,
}).then((res) => {
  if (res.code === 200) {
    console.log(res);
  }
});


</script>
<style lang="less" scoped></style>
